//可选参数：date，month，year
//给定date则查本周周记，返回ID和CONTENT
//给定month查本月周记，
//给定year查一年的周记
def user = session.appUser();
def todayDate = new Date().format('yyyy-MM-dd');

def date = request.getString('date');
def month = request.getLong('month');
def year = request.getLong('year');
// def thisMonth = request.getString('thisMonth');

if (date != null) {
	def id = db.find("select ID from WEEK where OPEN_ID=? and DATE=?",user.openId,date);
	if (!id) {
		return false;
	} else {
		def content = db.find('select CONTENT from WEEK where ID=?',id.ID)
		if (content != null) {
			return [id: id, content: content];
			} else {
				return id;
			}
		
	}
} else if (month != null && year != null) {
	def week = db.query("select CONTENT,DATE from WEEK where OPEN_ID=? and MONTH(DATE) = ? and YEAR(DATE) = ? order by DATE", user.openId,month,year);
	log.debug('week:{}',week);
	return week;
}
